﻿
using System;
using System.ComponentModel;



public class ClientLog
{
    /// <summary>
    /// 发送log
    /// </summary>
    public static string clientLogUrl = "https://www.petsfight.xyz:1901/clientlog";

    public static void Send(ClientLogId logId,string log)
    {
#if ClientLog
        try
        {
            long userId = 0;
            if(MGame.instance && MGame.instance.user != null)
                userId = MGame.instance.user.id;
            
            string url = $"{clientLogUrl}?userId={userId}&logId={logId}&log={log}";
            AsyncHttpRequest httpRequest = new AsyncHttpRequest(url);
            httpRequest.onResponse = delegate (AsyncHttpRequest request)
            {
                if (!string.IsNullOrEmpty(request.error))
                {
                    GameDebug.LogError(request.error);
                }
                else
                {
                    GameDebug.Log("SendClientLog suc");
                }
            };
            httpRequest.GET();
    }
        catch (Exception e)
        {
            GameDebug.LogException(e);
        }
#endif
    }
}